﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
        private int id;
        public Form3(int id, string Name, int Age, int Score)
        {
            InitializeComponent();
             this.id=id;
            textBox2.Text = Name;
            textBox3.Text = Age.ToString();
            textBox4.Text = Score.ToString();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            var Name = textBox2.Text;
            var Age = textBox3.Text;
            var Score = textBox4.Text;


                if (!string.IsNullOrEmpty(Name))
                {
                    var sql = string.Format("update Students set Name='{0}',Age='{1}',Score='{2}' where Id={3}", Name, Age, Score, this.id);
                    var res = DbHelper.AddOrEdiSave(sql);
                    if (res == 1)
                    {
                        MessageBox.Show("更新成功");
                        this.DialogResult = DialogResult.Yes;
                        this.Close();
                    }
                }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();

        }
    }
}
